package com.cares.user.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.sh.cares.dao.orm.hibernate.query.SafeDetachedCriteria;
import cn.sh.cares.dao.orm.hibernate.query.SafeRestrictions;

import com.cares.common.dao.impl.JsflowDaoImpl;
import com.cares.user.dao.UserDao;
import com.cares.user.entity.UserVO;

@Repository("userDao")
public class UserDaoImpl extends JsflowDaoImpl implements UserDao {

	public String queryLoginedUser(String username, String password) {
		SafeDetachedCriteria criteria = SafeDetachedCriteria.forClass(UserVO.class);
		
		criteria.add(SafeRestrictions.equal("userName", username));

		criteria.add(SafeRestrictions.equal("password", password));
		
		List<UserVO> results = getEntityManager().queryForListByCriteria(UserVO.class, criteria);
		if(null!=results && results.size()>0 ){
			return "0";
		}else{
			return "1";
		}
		
	}
	
	public void createUser(UserVO user){
		getEntityManager().save(user);
		
	}

}
